<!DOCTYPE html>
<html>
<head>
    <title>用户中心</title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <meta charset="utf-8" />
    <meta content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link href="Css/style.css" rel="stylesheet" type="text/css">
    <link href="Css/basic.css" rel="stylesheet" type="text/css">
    <link href="Css/usercenter.css" rel="stylesheet" type="text/css">
    <script src="Scripts/http.js"></script>
    <script type="text/javascript" src="Scripts/jquery-1.8.3.min.js"></script>
    <link rel="stylesheet" href="Css/common.css">
    <script type="text/javascript" src="Scripts/alertPopShow.js"></script>
    <script>
        /* 用途: 接收地直栏参数 取id=1 根据ID的值 */
        $(function(){
            //第一加载提货地点
            getaddress();
            function getaddress(){
                $.ajax({
                    url:url+'getAddress',
                    dataType:'json',
                    type:'post',
                    async:false,
                    data:{},
                    success:function(result){
                        var status = result.status;
                        var code = result.code;
                        if(status==1&&code=='1001'){
                            var data = result.data;
                            if(data.length>0){
                                var html='';
                                for(var i=0;i<data.length;i++){
                                    html +='<option value="'+data[i]['id']+'">'+data[i]['address']+'</option>';
                                }
                                $('#orderaddress').html(html);
                            }
                        }
                    },
                    error:function(result) {
                        console.log("error")
                    }
                });
            }

            aftersale = sessionStorage.getItem('rexian');
            if(aftersale!=''){
              $('.infor-rexian').html(aftersale);
             }
             $('#action').click(function(){
                 submit();
             });
            function submit(){
                var orderid = $('#orderid').val();
                if(orderid==''){
                    alert('订单号必填');
                    return;
                }
                var ordertime = $('#ordertime').find('option:selected').val();
                var orderaddress = $('#orderaddress').find('option:selected').text();
                if(ordertime==''&&orderaddress==""){
                    alert('取货时间和取货地点至少填一项！');
                    return;
                }
                var orderphone = $('#orderphone').val();
                if(orderphone==''){
                    alert('手机号必填');
                    return;
                }else if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(orderphone))){
                    alert('手机号格式不是正确');
                    return;
                }
                $.ajax({
                    url:url+'orderchange',
                    dataType:'json',
                    type:'post',
                    async:false,
                    data:{
                        orderid:orderid,
                        time:ordertime,
                        address:orderaddress,
                        phone:orderphone
                    },
                    success:function(result){
                        var status = result.status;
                        var code = result.code;
                        if(status==1&&code=='1001'){
                           alert('提交成功！');
                        }else{
                            alert('提交失败！');
                        }
                    },
                    error:function(result) {
                        console.log("error")
                    }
                });
            }

        })
    </script>
</head>
<body>

<div class="yintai-header">
    <a href="javascript:void(0);" class="back-button"></a>
    <div class="hear-name">用户订单修改</div>
    <div class="xiala"><span></span></div>
</div>

<div class="viewport">
    <input type="text" style="display: none" value="" id="ids">
    <div class="user-common user-phone" style="margin-top: 10px;">
        <a class="yintai-phone" href="javascript:void(0);">我的订单号(必填)：<div class="infor-phone"><span><input type="text" placeholder="请填写订单号"  id="orderid" required></span></div></a>
    </div>
    <div class="user-common user-phone" style="margin-top: 10px;">
        <a class="yintai-phone" href="javascript:void(0);">取花时间延迟：<div class="infor-phone"><span >
            <select id="ordertime" style="width:160px;">
                <option value="1">一周</option>
                <option value="2">二周</option>
                <option value="3">三周</option>
                <option value="4">四周</option>
           </select>
        </span>
        </div>
        </a>
    </div>
    <div class="user-common user-phone" style="margin-top: 10px;">
        <a class="yintai-phone" href="javascript:void(0);">修改订单提货点：<div class="infor-phone"><span >
            <select id="orderaddress" style="width:160px;">

           </select>
        </span>
        </div></a>
    </div>
    <div class="user-common user-phone" style="margin-top: 10px;">
        <a class="yintai-phone" href="javascript:void(0);">我的手机号(必填)：<div class="infor-phone"><span  ><input type="text" placeholder="请填您的手机" required id="orderphone"></span></div></a>
    </div>
    <div class="user-common user-phone" style="margin-top: 10px;">
        <a class="yintai-phone" href="javascript:void(0);">客服热线：<div class="infor-phone infor-rexian" style="width:100%;padding-left:200px;">138527067</div></a>
    </div>
    <div class="user-common user-phone" >
        <a class="yintai-phone" href="javascript:void(0);">操作：<div class="infor-phone" style="width:100%;text-align:center"><input type="button" id="action" class="button" value="提交" ></div></a>
    </div>
</div>
</body>
</html>
